<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="divport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="renderer" content="webkit">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
	<meta name="format-detection" content="telephone=no">
	<meta name="format-detection" content="email=no" />
	<meta name="screen-orientation" content="portrait">
	<meta name="x5-orientation" content="portrait">
	<meta name="browsermode" content="application">
	<meta name="x5-page-mode" content="app">
	<meta name="full-screen" content="yes">
	<meta name="x5-fullscreen" content="true">
	<meta name="msapplication-tap-highlight" content="no">
	<meta name="description" content="">
	<meta name="keywords" content="">
	<script src="https://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<script src="https://cdn.jsdelivr.net/npm/vue"></script>
	<script type="text/javascript" src="jweixin-1.3.2.js"></script>
	<script type="text/javascript" src="md5-1.js" charset="utf-8"></script>
	<script>
		sizeWindow();
		window.onresize = sizeWindow;

		function sizeWindow() {
			document.documentElement.style.fontSize = window.innerWidth / 3.75 + 'px';
		}
	</script>
</head>

<body>
	<div id="app" class="container">
		<div @click="login" class='subBtn'>进入投诉系统小程序
		</div>
	</div>
	<script>
		var app = new Vue({
			el: '#app',
			data: {
				openid: ''
			},
			mounted() {},
			methods: {
				getToken() {
					const formatNumber = n => {
						n = n.toString()
						return n[1] ? n : '0' + n
					}
					var date = new Date()
					const year = date.getFullYear()
					const month = date.getMonth() + 1
					const day = date.getDate()
					var dateStr = [year, month, day].map(formatNumber).join('')
					var API_KEY = 'l2V|gfZp{8`;jzR~6Y1_'
					return md5('402268348' + dateStr + API_KEY)
				},
				login() {
					var access_token = this.getToken()
					var data = {
						'openid': this.openid,
						'access_token': this.getToken()
					}
					$.ajax({
						url: 'https://neikong.chinahonden.com/api/secret/user_login',
						type: 'POST',
						data: data,
						contentType: false,
						processData: false,
						success: function (res) {
							if (data.code === 0) {
								// 推送到小程序
								wx.miniProgram.postMessage({
									data: res
								})
								// 回退
								wx.miniProgram.redirectTo({
									url: '/pages/index/index'
								})
							} else {
								alert('网络有问题。。。请稍后再试')
							}
						},
						complete: function () {}
					})
				},
			}
		})
	</script>
	<style>
		.container {
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			display: flex;
			align-items: center;
			justify-content: center
		}

		.subBtn {
			width: 80%;
			height: 0.5rem;
			background: #103557;
			color: #fff;
			font-size: 0.2rem;
			border-radius: 0.1rem;
			line-height: 0.5rem;
			text-align: center;
		}
	</style>

</body>

</html>